package com.jprocms.module.cms.dal.dataobject.content;

import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jprocms.module.cms.dal.dataobject.type.CmsTypeDO;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Objects;

/**
 * @TableName cms_content_type
 */
@NoArgsConstructor
@AllArgsConstructor
@KeySequence("cms_content_type") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库，可不写。
@TableName(value = "cms_content_type")
public class ContentTypeDO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 内容ID
     */
    private Long contentId;

    /**
     * typeId
     */
    private Long typeId;

    @JsonIgnore
    private ContentDO content = new ContentDO();

    private CmsTypeDO type = new CmsTypeDO();

    public ContentTypeDO(Long contentId, Long typeId) {
        this.contentId = contentId;
        this.typeId = typeId;
    }

    /**
     * 内容ID
     */
    public Long getContentId() {
        return contentId;
    }

    /**
     * 内容ID
     */
    public void setContentId(Long contentId) {
        this.contentId = contentId;
    }


    public Long getTypeId() {
        return typeId;
    }

    public void setTypeId(Long typeId) {
        this.typeId = typeId;
    }

    public ContentDO getContent() {
        return content;
    }

    public void setContent(ContentDO content) {
        this.content = content;
    }

    public CmsTypeDO getType() {
        return type;
    }

    public void setType(CmsTypeDO type) {
        this.type = type;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ContentTypeDO that = (ContentTypeDO) o;
        return Objects.equals(contentId, that.contentId) && Objects.equals(typeId, that.typeId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(contentId, typeId);
    }
}